﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<% 
    var c = ViewContext.RouteData.Values["Controller"].ToString();
    var h = 500;
    var he = h - 100;
    var f = true;
    var caz = ViewBag.Case as Case;
%>


<%=Html.Confirm(Mui.confirm_delete)%>
<%=Html.MakePopupForm("Edit", new[] { "id" }, title: "edit " + c, successFunction: "edit", height: he, fullScreen: f)%>

<script type="text/javascript">
    var page = 1;
    function addStart(d) { $(d).css('opacity', 0).prependTo("#list").animate({ opacity: 1 }, 600, 'easeInCubic'); }
    function addEnd(d) { $(d).css('opacity', 0).appendTo("#list").animate({ opacity: 1 }, 300, 'easeInCubic'); }

    function create(o) { $.get('<%=Url.Action("row")%>', { id: o.Id }, function (d) { addStart(d); }); }
    function edit(o) { $.get('<%=Url.Action("row")%>', { id: o.Id }, function (d) { $("#o" + o.Id).before(d).remove(); $("#o" + o.Id).hide().fadeIn('slow'); }); }
    var lfm;
    $(function () {
        regForm();
        $(this).ajaxComplete(regForm);
        $('#more').click(more);

        var json = {};
        $('input.sparam').each(function () {
            json[this.name] = this.value;
        });

        $('#sform').ajaxForm({
            data: json,
            success: function (d) {
                $("#list").html(d.rows);
                page = 1;
                if (d.more) $('#more').show(); else $('#more').hide();
                lfm = $('#sform').formSerialize();
            }
        }).submit();

        $('#sform input:text').keyup(function () { $('#sform').submit(); });
        $('#sform input:hidden').change(function () { $('#sform').submit(); });

    });

    function regForm() {
        $(".fconfirm").ajaxForm({ success: function (d) { $('#o' + d.Id).fadeOut('slow', function () { $(this).remove(); styleup(); }); } });
    }

    function more() {
        page++;
        $.post('<%=Url.Action("search")%>', lfm + '&page=' + page, function (d) {
            addEnd(d.rows);
            if (d.more) $('#more').show(); else $('#more').fadeOut('slow');
        });
    }        
</script>
<form id="sform" action='<%=Url.Action("search")%>' method="post">
<%=Html.Partial("searchbox")%>
</form>
<br />
<br />
<%=Html.Partial("header")%>
<br />
<table class="atbl">
    <thead>
        <%=Html.Partial("hrow")%>
    </thead>
    <tbody id="list">
    </tbody>
</table>
<br />
<a id="more" class="abtn" style="display:none;"><%=Mui.More%></a> 
